<template>
	<zh-select :placeholder="placeholder"
    :funcCode="props.funcCode"
	:cryptoEnabled="true"
    :url="props.url"
    v-bind="attrs"
    :mode="mode"
    searchField="searchText"
    :fieldNames="fieldNames"
    :lazy="true"
    :allowClear="allowClear"
    :timeout="timeout"
    v-model="value">
    <template #option="{ idcard,fullName }">
        <span>{{ fullName }}</span>
        <span>({{ idcard }})</span>
      </template>
  </zh-select>
</template>
<script lang="ts" setup name="zh-search-person">
import { itemProps } from '@/components/lib/base/props-item';
import itemController from '@/components/lib/base/controller-item';
//------------------接收传入参数(组件)-------------------
const props = defineProps({
  ...itemProps, // 基础属性
  modelValue: {
		type: [Number, String, Boolean, Array],
		default: undefined,
	},
  //类型：v-model 绑定的personId 或者idcard
  type: {
		type: String,
		default() {
			return 'personId';
		},
	},
  //模式，默认单选 multiple 多选
	mode: {
		type: String,
		default() {
			return '';
		},
	},
  //查询url
	url: {
		type: String,
		default() {
			return '';
		},
	},
	//查询功能编号
	funcCode: {
		type: String,
		default() {
			return 'personInfo0001';
		},
	},
  placeholder:{
		type: String,
		default:"请输入姓名或证件号码搜索"
	},
  allowClear: {
		type: Boolean,
		default: true,
	},
  timeout:Number
})
//------------------定义子组件---------------------------
const attrs = useAttrs();
const emit = defineEmits(['update:modelValue']);
const allAttrs = computed(() => {
	return Object.assign(props.extend, attrs);
});
//------------------内部变量定义-------------------------
let fieldNames=ref({ label: 'fullName', value: props.type, options: 'children' });
const { value } = itemController(props, allAttrs.value, emit);
//------------------定义调用方法-------------------------

//------------------初始化------------------------------
onMounted(()=>{

})
//------------设置给父组件调用的数据/方法(组件)-----------

</script>
<style lang="scss" scoped></style>
